<template>
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
        :page-sizes="[5, 10, 20, 50, 100]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
        :total="total">
    </el-pagination>
</template>

<script>
import { getWorkTableData } from '@/utils/table.js'
export default {
    props: {
        "total": Number,
        "url": String
    },
    data() {
        return {
            currentPage: 1,    // 当前页数
            pageSize: 10,     // 每页显示条数

        }
    },
    created() {
        // this.$parent 获取父组件
        // 这里通过this.$parent拿到父组件，然后用该方法可以直接给父组件传值，让父组件的tableData获得数据
        getWorkTableData(this.$parent, this.url, { page: this.currentPage, size: this.pageSize }, [
            "completed",
        ]);
    },
    methods: {
        handleSizeChange(val) {
            this.pageSize = val;
            this.currentPage = 1;
            getWorkTableData(this.$parent, this.url, { page: this.currentPage, size: this.pageSize }, ["completed",]);
        },
        handleCurrentChange(val) {
            this.currentPage = val;
            getWorkTableData(this.$parent, this.url, { page: this.currentPage, size: this.pageSize }, ["completed",]);
        },
    },
}
</script>